package metu.tespit.entity.course;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import metu.tespit.entitiy.accountManagement.User;

/**
 
 * @created May 23, 2012
 */

@Entity
@Table(name="projectDocument")
public class ProjectDocument implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 5901658001934704293L;

	@Id @GeneratedValue
	private Long id;
	
	@ManyToOne
	private Activity uploaderActivity;
	
	@ManyToOne
	private User uploader;
	
	@ManyToOne
	private ProjectTeam projectTeam;
	
	@Temporal(TemporalType.DATE)
	private Date uploadedDate;
	
	public Date getUploadedDate() {
		return uploadedDate;
	}

	public void setUploadedDate(Date uploadedDate) {
		this.uploadedDate = uploadedDate;
	}

	@Lob @Basic(fetch=FetchType.LAZY)
	@Column(length=16777250)
	private byte[] data; 
	
	private String fileName;
	
	private String contentType;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public User getUploader() {
		return uploader;
	}

	public void setUploader(User uploader) {
		this.uploader = uploader;
	}
	

	public ProjectTeam getProjectTeam() {
		return projectTeam;
	}

	public void setProjectTeam(ProjectTeam projectTeam) {
		this.projectTeam = projectTeam;
	}

	public void setUploaderActivity(Activity uploaderActivity) {
		this.uploaderActivity = uploaderActivity;
	}

	public Activity getUploaderActivity() {
		return uploaderActivity;
	}
	
	public Boolean uploadiBuProjectTeamMiYapmis(ProjectTeam projectTeam){
		if(this.getProjectTeam().equals(projectTeam)){
			return true;
		}
		return false;
	}

	public byte[] getData() {
		return data;
	}

	public void setData(byte[] data) {
		this.data = data;
	}

	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public String getContentType() {
		return contentType;
	}

	public void setContentType(String contentType) {
		this.contentType = contentType;
	}

}
